var assert     = require('assert'),
    utility    = require('system/utility'),
	Linq       = require('collections/linq'),
	LinqTests  = require('./linq.Tests');

ArrayEnumerableTests = (function () {
	var ArrayEnumerableTests = function() {
		var arraySequence = [1, 10, 100, 1000, 10000].asEnumerable();
		var emptySequence = [].asEnumerable();

		var testSets = [
			[1, 1, 1, 1, 1, 1, 1, 1, {}, {}]
		];

		var dataSets = [
			{
				enumerable : [].asEnumerable(),
				result : []
			},
			{
				enumerable : [1].asEnumerable(),
				result : [1]
			},
			{
				enumerable : [1, 2, 3].asEnumerable(),
				result : [1, 2, 3],
				enumerable2 : [1, 2, 3].asEnumerable(),
				result2 : [1, 2, 3]
			},
			{
				enumerable : testSets[0].asEnumerable(),
				result : testSets[0]
			},
		];

		var tests = {};

		utility.extend(
			true,
			tests,
			LinqTests(dataSets),
			{
				'count': function() {
					assert.equal(arraySequence.count(), 5);
					assert.equal(emptySequence.count(), 0);
					assert.equal(arraySequence.count('$<=100'), 3);
					assert.equal(emptySequence.count('$<=100'), 0);
				},
				'reverse': function() {
					assert.deepEqual(arraySequence.reverse().toArray(), [10000, 1000, 100, 10, 1]);
					assert.deepEqual(emptySequence.reverse().toArray(), []);
				}
			}
		);

		return tests;
	};

	return ArrayEnumerableTests;
})();

// Hook into commonJS module systems
if (typeof module !== 'undefined' && "exports" in module) {
  module.exports = ArrayEnumerableTests;
}